Fix issue TypeError: Cannot read properties of undefined (reading 'runs') at Module.get_playlist#20
Merged
vixalien merged 11 commits intovixalien:mainfrom Jul 18, 2025
Merged
Conversation
…ns') at Module.get_playlist
vixalien
reviewed
Jul 5, 2025
Co-authored-by: Angelo Verlain Shema <37999241+vixalien@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a runtime TypeError in the playlist functionality by adding defensive programming practices to handle undefined/null values. The changes primarily focus on preventing crashes when accessing properties of potentially undefined objects.
- Added optional chaining in
get_playlistto safely accessstraplineTextOne.runs - Enhanced
parse_song_artists_runswith input validation and null checks - Simplified the parsing logic and improved code readability with better loop structure
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/mixins/playlist.ts |
Added optional chaining to prevent TypeError when accessing straplineTextOne.runs |
src/parsers/songs.ts |
Added input validation, new Run interface, and simplified parsing logic with better error handling |
Owner
|
Hello, please don't mind copilot everytime (fix the last change and you'd be ready to go) |
Contributor
Author
|
Now it should be good, sorry @vixalien for the continuos copilot commit that make me had done changes and then revert them, damn AI |
vixalien
approved these changes
Jul 18, 2025
Owner
vixalien
left a comment
There was a problem hiding this comment.
LGTM.
Thanks for tolerating the Copilot bs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I was having an issue with the get_playlist method of this library, after getting some playlist from the get_home method when I was trying to get the details of the playlist it gave me this error:
TypeError: Cannot read properties of undefined (reading 'runs') at Module.get_playlist (file:///Users/myUser/myProject/node_modules/libmuse/esm/src/mixins/playlist.js:57:66).This pull request makes improvements to error handling and code readability in the playlist and song parsing functionality. The most notable changes include adding safety checks to prevent runtime errors and simplifying the
parse_song_artists_runsfunction.Error Handling Improvements:
src/mixins/playlist.ts: Updated theauthorsproperty in theget_playlistfunction to use optional chaining (?.) when accessingrunsto prevent potential runtime errors ifstraplineTextOneis undefined.src/parsers/songs.ts: Added a null check at the beginning of theparse_song_artists_runsfunction to return an empty array ifrunsis falsy, ensuring the function handles invalid input gracefully.Code Readability Enhancements:
src/parsers/songs.ts: Removed unnecessary whitespace and simplified the loop structure in theparse_song_artists_runsfunction for better readability.